home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -coverdisks- / 126a / football / user / combination.rexx next >
OS/2 REXX Batch file  |  1999-05-22  |  40KB  |  1,303 lines

  1. /* ***********************************************************************
  2.  
  3.    COMBINATION PROGRAM FOR FOOTBALL REXX SUITE
  4.   ---------------------------------------------
  5.     Copyright  Mark Naughton 1999
  6.                                         From an idea by Kevin Lambert
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       200499   After lifting code from other programs and tailoring
  11.                     it for this, this is now ready for testing.
  12.                     All working ok.
  13.            240499   Added league information from LStats.rexx.
  14.            250499   Fixed bug where percentages couldn't be calculated if
  15.                     the results/matches were zero - from LStats.
  16.  
  17.  
  18. **************************************************************************
  19.  
  20. Procedure
  21. ---------
  22.  
  23. 1. Check files exist.
  24. 2. Check options.
  25. 3. Read league name from 'df' file.
  26. 4. Depending on options selected, run the appropriate routine. These have
  27.    not been documented as they are covered in other files.
  28. 5. Display information.
  29. 6. IF option to write the files to a directory has not been chosen,
  30.    display data.
  31.  
  32. ************************************************************************** */
  33. PARSE ARG league_stuff
  34.  
  35. version      = 1
  36. input_file   = '.df'
  37. input2_file  = '.sf'
  38. league_file  = "Data/" || league_stuff
  39. league_title = '*LEAGUE_NAME='
  40. separator    = '*'
  41.  
  42.  
  43. /*******************************************************************/
  44. /* ** THESE PARAMETERS CAN BE CHANGED TO SUIT YOUR REQUIREMENTS ** */
  45. /*******************************************************************/
  46.  
  47. select_fixtures   = "YES"     /* or "NO" */
  48. select_statistics = "NO"
  49. select_table      = "NO"
  50. select_leaginfo   = "YES"
  51.  
  52. output_dir        = "NONE"    /* NONE redirects output to the   */
  53.                               /* console or enter complete path */
  54.                               /* for files to be written        */
  55.  
  56. /*******************************************************************/
  57.  
  58.  
  59. if exists(league_file || input_file) = 0  then exit
  60. if exists(league_file || input2_file) = 0 then exit
  61.  
  62.  
  63. select_fixtures   = upper(select_fixtures)
  64. select_statistics = upper(select_statistics)
  65. select_table      = upper(select_table)
  66. select_leaginfo   = upper(select_leaginfo)
  67.  
  68. if select_fixtures ~= "YES" & select_statistics ~= "YES" & select_table ~= "YES" & select_leaginfo ~= "YES" then do
  69.    say
  70.    say "ERROR :    (Combination)"
  71.    say
  72.    say "No options were selected."
  73.    exit
  74. end
  75.  
  76.  
  77. if open(datafile,league_file||input_file,'r') then do
  78.    do while ~eof(datafile)
  79.       line = readln(datafile)
  80.       if pos(league_title,line) > 0 then
  81.          title = delstr(line,1,13)
  82.    end
  83.    close(datafile)
  84. end
  85. else do
  86.    say
  87.    say "ERROR :    (Combination)"
  88.    say
  89.    say "Cannot open '"league_file||input_file"' for reading."
  90.    exit
  91. end
  92.  
  93.  
  94. if select_fixtures = "YES" then
  95.    call create_fixs(league_stuff,output_dir)
  96.  
  97. if select_statistics = "YES" then
  98.    tcount = create_statistics(league_stuff,output_dir)
  99.  
  100. if select_table = "YES" then
  101.    call create_table(league_stuff,output_dir)
  102.  
  103. if select_leaginfo = "YES" then
  104.    call create_linfo(league_stuff,output_dir)
  105.  
  106.  
  107. osl = 1
  108. say
  109. say center("Combination",78)
  110. say "-----------------------------------------------------------------------------------------"
  111. say
  112. say
  113. say center("League: "title,78)
  114. say
  115. say
  116. say
  117. if select_leaginfo = "YES" then do
  118.    if osl=1 then say "Options Selected:   League Information"
  119.    osl = 0
  120. end
  121. if select_statistics = "YES" then do
  122.    if osl=1 then say "Options Selected:   Team Statistics"
  123.             else say "                    Team Statistics"
  124.    osl = 0
  125. end
  126. if select_fixtures = "YES" then do
  127.    if osl=1 then say "Options Selected:   League Fixtures"
  128.             else say "                    League Fixtures"
  129.    osl = 0
  130. end
  131. if select_table = "YES" then do
  132.    if osl=1 then say "Options Selected:   League Table"
  133.             else say "                    League Table"
  134. end
  135. say
  136. if output_dir ~= "NONE" then do
  137.    say "The following files have been written to '"output_dir"' :"
  138.    say
  139.    if select_fixtures   = "YES" then say "        "league_stuff".fix"
  140.    if select_statistics = "YES" then say "        "league_stuff".Team<number 1-"tcount">.stat"
  141.    if select_table      = "YES" then say "        "league_stuff".tab"
  142.    if select_leaginfo   = "YES" then say "        "league_stuff".linf"
  143. end
  144. else do
  145.    say
  146.    say
  147.    say
  148.    if select_leaginfo = "YES" then do
  149.       say
  150.       say center("League Information",78)
  151.       say "-----------------------------------------------------------------------------------------"
  152.       say
  153.       say
  154.       if open(datafile,"RAM:"league_stuff".linf",'r') then do
  155.          do while ~eof(datafile)
  156.             line = readln(datafile)
  157.             say line
  158.          end
  159.          close(datafile)
  160.          say
  161.          say
  162.       end
  163.       else do
  164.          say
  165.          say "ERROR :    (Combination)"
  166.          say
  167.          say "Unable to open 'RAM:"league_stuff".linf' file."
  168.       end
  169.       say
  170.       filen = "RAM:"league_stuff".linf"
  171.       address command 'delete >NIL: 'filen
  172.    end
  173.    if select_statistics = "YES" then do
  174.       say
  175.       say
  176.       say center("Team Statistics",78)
  177.       say "-------------------------------------------------------------------------------"
  178.       say
  179.       say
  180.       do kk=1 to tcount
  181.          if open(datafile,"RAM:"league_stuff"_Team"kk".stat",'r') then do
  182.             do while ~eof(datafile)
  183.                line = readln(datafile)
  184.                say line
  185.             end
  186.             close(datafile)
  187.          end
  188.          else do
  189.             say
  190.             say "ERROR :    (Combination)"
  191.             say
  192.             say "Unable to open 'RAM:"league_stuff"_Team"kk".stat' file."
  193.          end
  194.          say
  195.          filen = "RAM:"league_stuff"_Team"kk".stat"
  196.          address command 'delete >NIL: 'filen
  197.       end
  198.    end
  199.    if select_fixtures = "YES" then do
  200.       say
  201.       say
  202.       say center("League Fixtures",78)
  203.       say "-----------------------------------------------------------------------------------------"
  204.       say
  205.       say
  206.       if open(datafile,"RAM:"league_stuff".fix",'r') then do
  207.          do while ~eof(datafile)
  208.             line = readln(datafile)
  209.             say line
  210.          end
  211.          close(datafile)
  212.       end
  213.       else do
  214.          say
  215.          say "ERROR :    (Combination)"
  216.          say
  217.          say "Unable to open 'RAM:"league_stuff".fix' file."
  218.       end
  219.       say
  220.       filen = "RAM:"league_stuff".fix"
  221.       address command 'delete >NIL: 'filen
  222.    end
  223.    if select_table = "YES" then do
  224.       say
  225.       say
  226.       say
  227.       say center("League Table",78)
  228.       say "-----------------------------------------------------------------------------------------"
  229.       say
  230.       say
  231.       say
  232.       say "    Team                               Pl Won Drw Lst GoalsF GoalsA    Pts     GoalDiff"
  233.       say "-----------------------------------------------------------------------------------------"
  234.       a = 1
  235.       if open(datafile,"RAM:"league_stuff".tab",'r') then do
  236.          do while ~eof(datafile)
  237.             line = readln(datafile)
  238.             if line ~= '' then do
  239.                if strip(substr(line,76,5)) = 0 then line=overlay("",line,76,5," ")
  240.                if a<10 then do
  241.                   if a = 1 then line = upper(line)
  242.                   say " "a") "line
  243.                end
  244.                else
  245.                   say a") "line
  246.                a = a + 1
  247.             end
  248.          end
  249.          close(datafile)
  250.       end
  251.       else do
  252.          say
  253.          say "ERROR :    (Combination)"
  254.          say
  255.          say "Unable to open 'RAM:"league_stuff".tab' file."
  256.       end
  257.       say
  258.       filen = "RAM:"league_stuff".tab"
  259.       address command 'delete >NIL: 'filen
  260.    end
  261. end
  262.  
  263. exit
  264.  
  265. /* Procedure --------------------------------------------------------- */
  266.  
  267. create_fixs : procedure
  268. parse arg league_table,output_dr
  269.  
  270. league_file = "Data/"league_table
  271. input_file  = '.df'
  272. input2_file = '.sf'
  273. autosched   = '*AUTOSCHD='
  274. separator   = '*'
  275. autos = 0
  276.  
  277. if open(datafile,league_file||input_file,'r') then do
  278.    do while ~eof(datafile)
  279.       line = readln(datafile)
  280.       if pos(autosched,line